package com.jdbc.dao;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.ws.Response;

import com.jdbc.tool.DBLianjie;

public class SelectUser extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
            doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
              
	}	

    public String foundUser(HttpServletRequest request, HttpServletResponse response){
		String UserName="";
 	Connection conn=null;
 	Statement stm=null;
	    ResultSet rs=null;
	    conn=DBLianjie.getconn();
	    
	    HttpSession session=request.getSession();
	    String username=(String) session.getAttribute("id");
	    try {
			stm=conn.createStatement();
			rs=stm.executeQuery("select * from emai_user where e_user_id='"+username+"'" );
			if(rs.next()){
			UserName=rs.getString("e_user_name");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} 
		return UserName;
    }
}
